package com.calvin.study.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.calvin.study.event.InventoryEventContent;
import com.calvin.study.event.UserSyncEventContent;
import com.calvin.study.event.publisher.BaseEventPublisher;

@RestController
@RequestMapping(value = "/event")
public class EventController {

	@Autowired
	private BaseEventPublisher publisher;

	@GetMapping(value = "/test1")
	public String test1() {
		UserSyncEventContent eventContent = new UserSyncEventContent();
		eventContent.setKey("9988");
		eventContent.setParameter("9988");
		publisher.publishEvent(eventContent);
		return "SUCCESS";
	}

	@GetMapping(value = "/test2")
	public String test2() {
		InventoryEventContent inventoryEventContent = new InventoryEventContent();
		inventoryEventContent.setKey("100778");
		inventoryEventContent.setParameter("100778");
		inventoryEventContent.setCurCondition(InventoryEventContent.CF_BOILSTATUS_OK);
		publisher.publishEvent(inventoryEventContent);
		return "SUCCESS";
	}

}
